package com.bd.scm.dao.mapper.approval;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.scm.domain.dto.approval.*;
import com.bd.scm.domain.dto.item.ItemDto;
import com.bd.scm.domain.dto.visitorDto.VisitOrderDto;
import com.bd.scm.domain.dto.visitorDto.VisitorApproveRecordParamDto;
import com.bd.scm.domain.models.approval.Approval;
import com.bd.scm.domain.models.user.UserInfo;
import com.bd.scm.domain.models.visitor.ReservationRecordDetails;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ApprovalMapper extends BaseMapper<Approval> {
    /**
     * 获取已部署的流程信息.
     *
     * @return
     */
    public List<ActReProcdefDto> getActReProcdefList();

    /**
     * 根据iD获取已部署的流程信息.
     *
     * @return
     */
    public BdKqApproveDto getBdKqApprove(String key);

    /**
     * 根据KEY的值获取记录条数.
     *
     * @param key
     * @return
     */
    public Integer getApproveCountByKey(String key);

    /**
     * 插入bBdKqApproval.
     *
     * @param actReProcdefDto
     */
    public void insertBdKqApproval(ActReProcdefDto actReProcdefDto);

    /**
     * 更新bBdKqApproval.
     *
     * @param actReProcdefDto
     */
    public void updateBdKqApproval(ActReProcdefDto actReProcdefDto);

    /**
     * 更新bd_kq_approval_detail.
     *
     * @param actReProcdefDto
     */
    public void updateFlowBindId(ActReProcdefDto actReProcdefDto);

    /**
     * 获取流程明细记录根据流程id和key.
     *
     * @param bdKqApproveDto
     * @return
     */
    List<BdKqApproveDetailDto> getBdKqApproveDetail(BdKqApproveDto bdKqApproveDto);

    /**
     * 根据groupId获取人员id集合.
     *
     * @param groupId
     * @return
     */
    List<String> getIdByGroupId(Integer groupId);

    /**
     * 保存审批记录.
     *
     * @param bdKqApprovalrecordDto
     */
    void saveApprovalRecord(BdKqApprovalrecordDto bdKqApprovalrecordDto);

    /**
     * 获取指定实例流程拒绝的审批记录条数.
     *
     * @param bdKqApprovalrecordDto
     */
    Integer getCountByApprovalRecord(BdKqApprovalrecordDto bdKqApprovalrecordDto);

    /**
     * 根据实例id获取已审批记录.
     *
     * @param processId
     * @return
     */
    List<BdKqApprovalrecordDto> getBdKqApprovalRecordList(String processId);

    /**
     * 根据实例id获取orderId.
     *
     * @param list
     * @param type "work"/"leave"
     * @return
     */
    List<String> getOrderIdByProcess(@Param("list") List<String> list, @Param("recordType") String type);


    /**
     * 获取登录人已审批加班单.
     *
     * @param overTimeDataDto
     * @return
     */
    List<OverTimeDataDto> getOverTimeListNot(OverTimeDataDto overTimeDataDto);

    /**
     * 获取登录人未审批的加班单.
     *
     * @param overTimeDataDto
     * @return
     */
    List<OverTimeDataDto> getOverTimeListAppr(OverTimeDataDto overTimeDataDto);

    /**
     * 获取登录人已审批和未审批的加班单.
     *
     * @param overTimeDataDto
     * @return
     */
    List<OverTimeDataDto> getOverTimeListAll(OverTimeDataDto overTimeDataDto);

    /**
     * 获取登录人已审批请假单.
     *
     * @param leaveDataDto
     * @return
     */
    List<LeaveDataDto> getLeaveListNot(LeaveDataDto leaveDataDto);

    /**
     * 获取登录人未审批的请假单.
     *
     * @param leaveDataDto
     * @return
     */
    List<LeaveDataDto> getLeaveListAppr(LeaveDataDto leaveDataDto);

    /**
     * 获取登录人已审批和未审批的请假单.
     *
     * @param leaveDataDto
     * @return
     */
    List<LeaveDataDto> getLeaveListAll(LeaveDataDto leaveDataDto);

    /**
     * 判断登录人是否是部门总监，查询到就是，查询不到就不是.
     *
     * @param userSerial
     * @return
     */
    Integer findDeptDirector(@Param("userSerial") String userSerial);

    /**
     * 获取部门总监管辖人员.
     *
     * @param userSerial
     * @return
     */
    List<Long> getUsersByDeptDirector(@Param("userSerial") String userSerial);

    /**
     * 根据id获取审批组人员.
     *
     * @param itemDto
     * @return
     */
    List<UserInfo> getUsersByGroupId(@Param("itemDto") ItemDto itemDto);

    /**
     * 添加人员到审批组.
     *
     * @param groupId
     * @param userIds
     */
    void addApprovalUsers(@Param("groupId") Integer groupId, @Param("userIds") List<Long> userIds);

    /**
     * 移除审批组人员.
     *
     * @param addApprovalUserDto
     */
    void deleteApprovalUsers(@Param("addApprovalUserDto") AddApprovalUserDto addApprovalUserDto);

    /**
     * 补出勤所有审批数据
     * @param repairDataDto
     * @return
     */
    List<RepairDataDto> getRepairListAll(RepairDataDto repairDataDto);

    /**
     * 补出勤未审批数据
     * @param repairDataDto
     * @return
     */
    List<RepairDataDto> getRepairListNot(RepairDataDto repairDataDto);

    /**
     * 补出勤已审批数据
     * @param repairDataDto
     * @return
     */
    List<RepairDataDto> getRepairListAppr(RepairDataDto repairDataDto);

    /**
     * 获取登录人已审批和未审批的访客单2.
     *
     * @param page
     * @param visitParams
     * @return
     */
    IPage<VisitOrderDto> getVisitorOrderListNot(Page<VisitOrderDto> page,
                                              VisitorApproveRecordParamDto visitParams);
    /**
     * 获取登录人已审批和未审批的访客单2.
     *
     * @param page
     * @param visitParams
     * @return
     */
    IPage<VisitOrderDto> getVisitorOrderListAppr(Page<VisitOrderDto> page,
                                                 VisitorApproveRecordParamDto visitParams);

    /**
     * 获取审批单明细.
     *
     * @param visitorApproveRecordParamDto
     * @return
     */
    ReservationRecordDetails getVisitorOrderDetail(VisitorApproveRecordParamDto visitorApproveRecordParamDto);
}
